package cassys.actions.assessmentManagement;

import cassys.actions.core.BaseAction;
import cassys.domain.assessment.Assessment;
import cassys.domain.assessment.AssessmentItem;
import cassys.domain.assessment.MarkRange;
import cassys.domain.classManagement.Module;
import cassys.ejb.clients.AssessmentManagementDelegate;
import java.util.Collection;

/**
 *
 * @author User
 */
public class ViewAssessment extends BaseAction {

    private Long assessmentId;
    private String title;
    private String description;
    private int maxMark;
    private MarkRange markRange;
    private Collection<AssessmentItem> assessmentItems;
    private Module module;
    private double weightPercentage;
    private AssessmentManagementDelegate assessmentDelegate;

    public ViewAssessment() {
        assessmentDelegate = new AssessmentManagementDelegate();

    }

    @Override
    public String execute() throws Exception {
        System.out.println("assessment management action started");
        setAssessmentId((Long) Long.parseLong(request.getParameter("assessmentId")));
        Assessment existingAssessment = assessmentDelegate.findByAssessmentId(this.getAssessmentId());
        System.out.println(existingAssessment.getTitle());
        this.setTitle(existingAssessment.getTitle());
        this.module = existingAssessment.getModule();
        System.out.println("module code : " + existingAssessment.getModule().getModuleCode());
        System.out.println("title : " + existingAssessment.getTitle());
        this.setDescription(existingAssessment.getDescription());
        System.out.println("description : " + existingAssessment.getDescription());
        this.setMarkRange(existingAssessment.getMarkRange());
        System.out.println("range max : " + existingAssessment.getMarkRange().getMax());
        this.setMaxMark(existingAssessment.getMaxMark());
        this.setAssessmentItems(existingAssessment.getAccessmentItems());
        System.out.println("assessment items : " + existingAssessment.getAccessmentItems().size());
        //this.assessmentDTO = assessmentDelegate.findByAssessmentId(assessmentId);
        return SUCCESS;
    }

    public String updateAssessment() throws Exception {
        System.out.println("invoke create assessment action");
        // assessmentDelegate.updateAssessment(assessmentDTO);
        return SUCCESS;
    }

    public String deleteAssessment() throws Exception {
        System.out.println("invoke create assessment action");
        //assessmentDelegate.deleteAssessment(assessmentDTO);
        return SUCCESS;
    }

    /**
     * @return the assessmentId
     */
    public Long getAssessmentId() {
        return assessmentId;
    }

    /**
     * @param assessmentId the assessmentId to set
     */
    public void setAssessmentId(Long assessmentId) {
        this.assessmentId = assessmentId;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param title the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the maxMark
     */
    public int getMaxMark() {
        return maxMark;
    }

    /**
     * @param maxMark the maxMark to set
     */
    public void setMaxMark(int maxMark) {
        this.maxMark = maxMark;
    }

    /**
     * @return the markRange
     */
    public MarkRange getMarkRange() {
        return markRange;
    }

    /**
     * @param markRange the markRange to set
     */
    public void setMarkRange(MarkRange markRange) {
        this.markRange = markRange;
    }

    /**
     * @return the assessmentItems
     */
    public Collection<AssessmentItem> getAssessmentItems() {
        return assessmentItems;
    }

    /**
     * @param assessmentItems the assessmentItems to set
     */
    public void setAssessmentItems(Collection<AssessmentItem> assessmentItems) {
        this.assessmentItems = assessmentItems;
    }

    /**
     * @return the module
     */
    public Module getModule() {
        return module;
    }

    /**
     * @param module the module to set
     */
    public void setModule(Module module) {
        this.module = module;
    }

    /**
     * @return the weightPercentage
     */
    public double getWeightPercentage() {
        return weightPercentage;
    }

    /**
     * @param weightPercentage the weightPercentage to set
     */
    public void setWeightPercentage(double weightPercentage) {
        this.weightPercentage = weightPercentage;
    }
}
